home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / bin / startx < prev    next >
Text File  |  2006-04-12  |  3KB  |  157 lines

  1. #!/bin/sh
  2.  
  3. # $Xorg: startx.cpp,v 1.3 2000/08/17 19:54:29 cpqbld Exp $
  4. #
  5. # This is just a sample implementation of a slightly less primitive
  6. # interface than xinit.  It looks for user .xinitrc and .xserverrc
  7. # files, then system xinitrc and xserverrc files, else lets xinit choose
  8. # its default.  The system xinitrc should probably do things like check
  9. # for .Xresources files and merge them in, startup up a window manager,
  10. # and pop a clock and serveral xterms.
  11. #
  12. # Site administrators are STRONGLY urged to write nicer versions.
  13. #
  14. # $XFree86: xc/programs/xinit/startx.cpp,v 3.16tsi Exp $
  15.  
  16.  
  17. userclientrc=$HOME/.xinitrc
  18. userserverrc=$HOME/.xserverrc
  19. sysclientrc=/etc/X11/xinit/xinitrc
  20. sysserverrc=/etc/X11/xinit/xserverrc
  21. defaultclientargs=""
  22. defaultserverargs="-nolisten tcp -br"
  23. clientargs=""
  24. serverargs=""
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. if [ -f $userclientrc ]; then
  32.     defaultclientargs=$userclientrc
  33. elif [ -f $sysclientrc ]; then
  34.     defaultclientargs=$sysclientrc
  35. fi
  36.  
  37.  
  38.  
  39.  
  40. if [ -f $userserverrc ]; then
  41.     defaultserverargs=$userserverrc
  42. elif [ -f $sysserverrc ]; then
  43.     defaultserverargs=$sysserverrc
  44. fi
  45.  
  46. whoseargs="client"
  47. while [ x"$1" != x ]; do
  48.     case "$1" in
  49.       /''*|\.*)       if [ "$whoseargs" = "client" ]; then
  50.                   if [ "x$clientargs" = x ]; then
  51.                       clientargs="$1"
  52.                   else
  53.                       clientargs="$clientargs $1"
  54.                   fi
  55.               else
  56.                   if [ "x$serverargs" = x ]; then
  57.                       serverargs="$1"
  58.                   else
  59.                       serverargs="$serverargs $1"
  60.                   fi
  61.               fi ;;
  62.       --)     whoseargs="server" ;;
  63.       *)      if [ "$whoseargs" = "client" ]; then
  64.                   if [ "x$clientargs" = x ]; then
  65.                       clientargs="$defaultclientargs $1"
  66.                   else
  67.                       clientargs="$clientargs $1"
  68.                   fi
  69.               else
  70.                   case "$1" in
  71.                       :[0-9]*) display="$1"; serverargs="$serverargs $1";;
  72.                       *) serverargs="$serverargs $1" ;;
  73.                   esac
  74.               fi ;;
  75.     esac
  76.     shift
  77. done
  78.  
  79. if [ x"$clientargs" = x ]; then
  80.     clientargs="$defaultclientargs"
  81. fi
  82. if [ x"$serverargs" = x ]; then
  83.     serverargs="$defaultserverargs"
  84. fi
  85.  
  86. if [ x"$XAUTHORITY" = x ]; then
  87.     XAUTHORITY=$HOME/.Xauthority
  88.     export XAUTHORITY
  89. fi
  90.  
  91. removelist=
  92.  
  93.  
  94. # set up default Xauth info for this machine
  95. case `uname` in
  96. Linux*)
  97.     if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
  98.         hostname=`hostname -f`
  99.     else
  100.         hostname=`hostname`
  101.     fi
  102.     ;;
  103. *)
  104.     hostname=`hostname`
  105.     ;;
  106. esac
  107.  
  108. authdisplay=${display:-:0}
  109. mcookie=`mcookie`
  110. for displayname in $authdisplay $hostname$authdisplay; do
  111.     if ! xauth list "$displayname" | grep "$displayname " >/dev/null 2>&1; then
  112.         xauth -q << EOF 
  113. add $displayname . $mcookie
  114. EOF
  115.     removelist="$displayname $removelist"
  116.     fi
  117. done
  118.  
  119.  
  120. cleanup() {
  121.     [ -n "$PID" ] && kill $PID > /dev/null 2>&1
  122.  
  123.  
  124. if [ x"$removelist" != x ]; then
  125.     xauth remove $removelist
  126. fi
  127.  
  128.  
  129.  
  130.  
  131.  
  132. if command -v deallocvt > /dev/null 2>&1; then
  133.     deallocvt
  134. fi
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145. }
  146.  
  147.  
  148. trap cleanup 0
  149.  
  150. xinit $clientargs -- $serverargs -deferglyphs 16 &
  151.  
  152. PID=$!
  153.  
  154. wait $PID
  155.  
  156. unset PID
  157.